package com.joy.common.model.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.google.common.collect.Lists;
import lombok.Data;

import java.util.List;

/**
 * @Description 资源VO
 * @Author yjzhao
 * @Date 2019/9/16 16:26
 **/
@Data
public class ResourceVO {


    private String id;

    private String resourceName;

    private String resourceEname;

    private String type;

    private String url;

    private String parentId;

    private String permission;

    private Integer sort;

    private String iconCls;

    private String code;

    /**
     * 是否显示
     */
    private Boolean isShow;
    /** 子资源 **/
    private List<ResourceVO> childsResourceList = Lists.newArrayList();
    /** 是否有子项 **/
    private boolean notEnd;
    public boolean getNotEnd() {
        if (CollectionUtils.isNotEmpty(this.getChildsResourceList())) {
            return true;
        }
        return false;
    }

    /** 是否打开 */
    //private String active;
    public String active(String code) {
        if(StrUtil.isNotBlank(code) && StrUtil.isNotBlank(getCode())) {
            if(code.equals(getCode())) {
                return "active";
            }
            if(code.startsWith(getCode())) {
                return " active open";
            }
        }



        return "";
    }
}
